package com.tuanzi.loan.business.service.sms;

import java.util.Date;
import java.util.List;
import java.util.Map;

import org.springframework.data.domain.Page;

import com.tuanzi.loan.business.entity.sms.SmsSendTask;
import com.tuanzi.loan.business.entity.sms.SmsSendTaskStatus;
import com.tuanzi.loan.core.service.CommonService;
import com.tuanzi.loan.core.vo.PageSearcher;
import com.tuanzi.loan.vo.request.family.SmsSendTaskSearchRequest;
import com.tuanzi.loan.vo.response.family.SmsSendTaskSearchResponse;

import lombok.Data;

/**
 * @author Ray 2017/12/12
 */
public interface SmsSendTaskService extends CommonService<SmsSendTask, Long> {

	SmsSendTask addSmsSendTask(Long calculateTaskId);

	SmsSendTask findTopOneByStatusAndExecuteTimeBefore(SmsSendTaskStatus status, Date executeDate);

	void updateStatusWithoutTransactional(SmsSendTask smsSendTask, SmsSendTaskStatus status);

	List<SmsSendTask> findByStatus(SmsSendTaskStatus status);

	Page<SmsSendTaskSearchResponse> list(PageSearcher<SmsSendTaskSearchRequest> pageSearcher);

	SmsSendTask findTopOneByStatus(SmsSendTaskStatus status);

	SmsSendTask resend(Long smsSendTaskId);

	Long countByStatus(SmsSendTaskStatus status);

	void sendSms(SmsSendTask smsSendTask);

	void cancelTask(Long smsSendTaskId);
	
	Map<String, String> findDistinctFirstNames();

	@Data
	final class SmsPlatformResult {
		private String status;

		private String message;

		private Long remainPoint;

		private String taskId;

		private Long successCounts;

		public boolean isSuccess() {
			return "Success".equalsIgnoreCase(status);
		}
	}

}
